
#include "bsp_system.h"

static uint32_t delay_cnt;

void system_init(void)
{
	if (SysTick_Config(SystemCoreClock / 1000))
	{
		while (1) // 滴答定时器设置失败
			;
	}
}

void delay_ms(uint32_t time_count)
{
	delay_cnt = time_count;

	while (delay_cnt != 0)
		;
}

void delay_sw_us(uint32_t count)
{
	uint32_t sw_count = count;
	while (sw_count != 0)
	{
		sw_count--;
		for (uint32_t i = 0; i < 4; i++)
			;
	}
}
void delay_sw_ms(uint32_t count)
{
	uint32_t sw_count = count;
	while (sw_count != 0)
	{
		sw_count--;
		for (uint32_t i = 0; i < 6700; i++)
			;
	}
}

void SysTick_Handler(void)
{
	if (delay_cnt != 0)
		delay_cnt--;
}
